//
//  Contants.m
//  MHO
//
//  Created by papo on 2/17/14.
//  Copyright (c) 2014 maihoang. All rights reserved.
//

#import "Contants.h"


@implementation ServiceResult

+ (ServiceResult*)result:(BOOL)succes message:(NSString *)message {
    ServiceResult* s = [[ServiceResult alloc] init];
    s.success = succes;
    s.message = message;
    return s;
}

@end

@implementation Contants

+ (NSString*)urlForKey:(NSString *)key {
    return [NSString stringWithFormat:@"%@%@", kServerUrl, key];
}

+ (NSString*)gameUrlForKey:(NSString *)key {
    return [NSString stringWithFormat:@"%@%@", kServerUrl2, key];
}

+ (NSString*)gameUrlWithGenre:(int)genre platform:(int)platform publisher:(int)publisher hot:(int)hot news:(int)news mostView:(int)mostView pageIndex:(int)index pageSize:(int)size {
    return [self gameUrlForKey:[NSString stringWithFormat:kServiceGameFormat, genre, platform, publisher, hot, news, mostView, index, size]];
}

+ (NSString*)gameUrlWithCategory:(int)category idSystem:(int)idSystem idGroup:(int)idGroup isHot:(int)isHot isNew:(int)isNew mostView:(int)mostView pageIndex:(int)index pageSize:(int)size key:(NSString *)key {
    return [self gameUrlForKey:[NSString stringWithFormat:kServiceGameFormat, category, idSystem, idGroup, isHot, isNew, mostView, index, size, key]];
}

+ (NSURL*)getImageUrl:(NSString *)url width:(int)width height:(int)height {
    NSString* s = [NSString stringWithFormat:@"http://farm.mho.vn/srv_thumb.ashx?w=%d&h=%d&name=", width, height];
    NSString* str = [url stringByReplacingOccurrencesOfString:@"http://farm.mho.vn/" withString:s];
//    NS
    if (!([str hasPrefix:@"http://"] || [str hasPrefix:@"https://"]))
    {
        // do something
        str = [@"http://" stringByAppendingString:str];
    }
    return [NSURL URLWithString:str];
}

+ (NSURL*)getAppPictureAlbumUrl:(NSString *)url {
    return [NSURL URLWithString:url];
}
@end
